<!--

    Copyright (C) 2011-2012 Luca Li Greci

    This file is part of pojo-creator

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<body>
   <h1>The POJO Creator Library.</h1>
   <p>This java library provides facilities for programmatically
      generating POJO objects with all fields populated randomly or from
      a defined data set.</p>
   <p>The main idea is that whichever functionality in your
      application needs to be tested you still have to create an
      instance of your model with the fields set properly for the
      purpose of the test. To give you a better idea, we need to
      distinguish by type of test.</p>
   <p>Let's assume we have an application with the Service and DAO
      layer, in this scenario we should have:
   <ul>
      <li><b>Unit testing</b>: Mock the database and exercise the
         functionality, however you still need the model and you want
         the fields set properly.</li>
      <li><b>Integration test</b>: Let's say we use an in-memory
         database (e.g. HSQLDB) and test the functionality, but you
         still need the model and you want the fields set properly.</li>
      <li><b>Performance test</b>: You want to test the application
         throughput, for instance in a MOM architecture this means to
         understand the number of massages the application can process
         per second. You don't care about the data you just need an high
         volume of data set. You still need to create the model.</li>
      <li><b>Load test</b>: You want to test what is going to
         happen when a massive volume of data is processed by the
         application (e.g.: a social web site with thousands of
         concurrent requests). You still need to create the model even
         though you don't care about the data.</li>
      <li><b>Soak test</b>: You want to test the system with a
         significant load extended over a defined period of time, pause
         the test execution and re start it after a while. For instance,
         you will need to know how the system behaves during the peak time and
         then followed by a period of normal activity, followed by a
         period of idle activity time. You still need to create the
         model even though you don't care about the data.</li>
   </ul>

   <p>
   <p>The main classes in the library are:
   <ol>
      <li><b>{@link com.pojocreator.Creator}</b> which allows the
         creation and setting of the object properties.</li>
      <li><b>{@link com.pojocreator.provider.DataProvider}</b>
         which defines the main interface to generate and define a data
         set of:
         <ul>
            <li>Date</li>
            <li>Number</li>
            <li>String</li>
            <li>Character</li>
         </ul></li>
      <li><b>{@link com.pojocreator.provider.Provider}</b> an
         utility class that exposes methods to access all available data
         providers.</li>
   </ol>
   <h3>Examples</h3>
   <p>Let's say we have a POJO class that represents a student:
   <pre>
public class Student {
   private Integer id;
   private String firstname;
   private String lastname;
   
   /**
   * @return the id
   */
   public Integer getId() {
     return id;
   }

   /**
   * @param id the id to set
   */
   public void setId(Integer id) {
     this.id = id;
   }
   
   /**
   * @return the firstname
   */
   public String getFirstname() {
     return firstname;
   }
   
   /**
   * @param firstname the firstname to set
   */
   public void setFirstname(String firstname) {
     this.firstname = firstname;
   }
   
   /**
   * @return the lastname
   */
   public String getLastname() {
     return lastname;
   }
   
   /**
   * @param lastname the lastname to set
   */
   public void setLastname(String lastname) {
     this.lastname = lastname;
   }
 }
    </pre>
   To create a single instance:
   <pre>
   // Import static for convenience
   import static com.pojocreator.Creator.many;
   import static com.pojocreator.Creator.one;
   import static com.pojocreator.Creator.with;
   
   public void createSingleStudent() {
     Student student = one(Student.class, with("id", 100), with("firstname", "Luca"), with("lastname", "Rossi"));
     assertNotNull("Student should not be null", student);
     assertEquals("Student has a wrong ID", 100, student.getId().intValue());
     assertEquals("Student with wrong firstname", "Luca", student.getFirstname());
     assertEquals("Student with wrong lastname", "Rossi", student.getLastname());
   }
       </pre>
</body>
